#pragma once
#include "../network/udp_handler.hpp"
#include "../buffer/image_buffer.hpp"
#include "../inference/lanenet_inference.hpp"
#include <vector>
#include <thread>
#include <atomic>
#include <memory>

class SystemManager {
public:
    SystemManager(std::unique_ptr<UDPHandler> udp,
                 std::unique_ptr<ImageBuffer> buffer,
                 std::unique_ptr<LanenetInference> inference)
        : udp_(std::move(udp))
        , buffer_(std::move(buffer))
        , inference_(std::move(inference)) {}

    bool init();
    void start();
    void stop();

private:
    std::unique_ptr<UDPHandler> udp_;
    std::unique_ptr<ImageBuffer> buffer_;
    std::unique_ptr<LanenetInference> inference_;
    
    std::vector<std::thread> threads_;
    std::atomic<bool> running_{false};

    // 线程函数
    void receiver_thread();
    void inference_thread();
    void monitor_thread();
}; 